import Vue from 'vue'//引入vue
import VueRouter from 'vue-router'//引入vue-router依赖
Vue.use(VueRouter);//把vueRouter依赖注入到vue里面

import HelloWorld from '../components/HelloWorld.vue'//引入页面
import About from '../views/about.vue'//引入页面
import newsDea from '../views/newsDea.vue'//引入页面
import User from '../views/user.vue'//引入页面

const routes = [
  {
    path:'/',
    redirect:'/AAA',//路由重定向的两种方式
    // redirect:{name:'name1'},
  },
  {
    path:'/AAA',
    name:'name1',
    // component:()=>import('../components/HelloWorld.vue')//路由懒加载 页面初始不加载用户访问时候再加载
    component:HelloWorld,//匹配寻找相对应的文件夹
    // redirect:'/about',
    //  meta:{
    //    isShowFooter:false
    //  }
  },
  {
    path:'/about',
    name:'name2',
    component:About,
    alias:'/ab',//别名
    // components:{//页面分区块显示
    //   default:HelloWorld,
    //   right:About,
    //   bottom:newsDea
    // },
    meta:{
      isShowFooter:true,
      title:'头部'
    }
  },
  {
    path:'/news/Dea/:a/:b',//路由跳转带参数
    name:'newsDea',
    component:newsDea,
  },
  {//嵌套路由 
    path:'/user',
    component:User,
    redirect:'/user/set',
    children:[//子路由路由懒加载的方式
      {
        path:'set',
        name:'set',
        component:() => import('../views/set.vue'),
        meta:{
          show:true
        }
      },
      {
        path:'msg',
        name:'msg',
        component:() => import('../views/msg.vue'),
        meta:{
          isShowFooter:true
        }
      },
      {
        path:'news',
        name:'news',
        component:() => import('../views/news.vue')
      },
    ]
  },
  // {
  //   path:'/news/Dea',
  //   name:'newsDea',
  //   component:newsDea,
  // },
]
const router = new VueRouter({
  mode:'history',
  base:'/',
  routes//声明路由表
});

export default  router //导出路由对象
